package com.chenjun.designpattern.structural.proxy;

/**
 * JDK中的典型的代理模式： Thread就是一个代理模式，他implements Runnable同时又存了一个Runnable的引用
 * 
 * @author admin
 *
 */
public class 代理模式2
{

	public static void main(String[] args)
	{
		new TargetProxy(new Target()
		{
			@Override
			public void operate()
			{
				System.out.println("realTarget.operate.....");
			}
		}).operate();;
	}
}

interface Target
{
	public void operate();
}

class TargetProxy implements Target
{
	private Target realTarget;

	public TargetProxy(Target realTarget)
	{
		this.realTarget = realTarget;
	}

	@Override
	public void operate()
	{
		System.out.println("before realTarget");
		realTarget.operate();
		System.out.println("after realTarget");
	}
}
